﻿$(function () {
    $("#register").hide();
    $(".registrationStep:first").fadeIn('slow');

    $("#back").hide().click(function () {
        $(".registrationStep2").slideUp('slow');
        $(".registrationStep").show('slow');
        $("#back").hide();
        $("#next").show();
        $("#register").hide();
    });

    $("#next").click(function (event) {
        event.preventDefault();
        var $step = $(".registrationStep:visible"); // get current step
        var validator = $("form").validate(); // obtain validator
        var anyError = false;

        $step.find("input:not(:hidden)").each(function () {
            if (!validator.element(this))  // validate every input element inside this step
                anyError = true;
        });

        if (anyError)
            return false;

        $(".registrationStep").slideUp('slow');
        $(".registrationStep2").show('slow');  // show it and hide current step
        $("#back").show();   // recall to show backStep button
        $("#next").hide();
        $("#register").show();
    });

    $(".tos").click(function (event) {
        event.preventDefault();
        $(".terms").toggle();
    });
});